﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace pufflesweb
{
    public partial class Auserupdate : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string AID = Request.QueryString["AID"];

                PModel.Admin admin = PBLL.Admin.Getuser(int.Parse(AID));

                this.aname.Text = admin.Aname;
                this.apassword.Text = admin.Apassword.ToString();
                this.aage.Text = admin.Aage.ToString();
                this.ajbo.Text = admin.Ajbo;
                this.Drop.Text = admin.Asex.ToString();
                this.HiddenField1.Value = admin.AID.ToString();
            }
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            PModel.Admin myuser = new PModel.Admin();
            myuser.AID = int.Parse(this.HiddenField1.Value);
            myuser.Aname = this.aname.Text;
            myuser.Apassword = int.Parse(this.apassword.Text);
            myuser.Aage = int.Parse(this.aage.Text);
            myuser.Ajbo = this.ajbo.Text;
            myuser.Asex = int.Parse(this.Drop.Text);

            if (PBLL.Admin.update(myuser))
            {
                PF.JsHelper.AlertAndParentUrl("修改保存成功", "main.aspx");
            }
            else
            {
                PF.JsHelper.AlertAndParentUrl("修改失败,请重新输入", "Auser.aspx");
            }
        }
    }
}